package com.hrc.springbootdemo.ws.origin;

import jakarta.websocket.OnMessage;
import jakarta.websocket.OnOpen;
import jakarta.websocket.Session;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.stereotype.Component;


@ServerEndpoint("/websocket")
@Component
public class MyWebSocket {

    @OnOpen
    public void onOpen(Session session) {
        System.out.println("Connected: " + session.getId());
    }

    @OnMessage
    public String onMessage(String message, Session session) {
        System.out.println("Received: " + message);
        return "Echo: " + message;
    }
}